package com.boarsoft.boar.batch.bean;

import java.io.Serializable;

import com.boarsoft.common.Util;

public class BatchSchedule implements Serializable, Comparable<BatchSchedule> {

	private static final long serialVersionUID = -5970375344909539041L;

	public static final short STATUS_DISABLE = 0;
	public static final short STATUS_ENABLE = 1;

	/** 同info.id */
	protected String id;
	/** 同info.code */
	protected String code;
	/** 同info.catalog */
	protected String catalog;
	/** 定时器执行对象 */
	protected String impl;
	/** 定时器描述 */
	protected String memo;
	/** 定时计划CRON表达式 */
	protected String cron;
	/** 定时计划开始时间 */
	protected String startTime;
	/** 定时计划终止时间 */
	protected String endTime;
	/** QuartzJob类 */
	protected String job;

	protected String nextFireTime;
	protected String previousFireTime;

	@Override
	public int compareTo(BatchSchedule o) {
		if (o == null) {
			return 1;
		}
		String nft = o.getNextFireTime();
		if (Util.strIsNotEmpty(nft) && Util.strIsNotEmpty(nextFireTime)) {
			return nft.compareToIgnoreCase(nextFireTime);
		}
		if (Util.strIsEmpty(nft) && Util.strIsNotEmpty(nextFireTime)) {
			return -1;
		}
		if (Util.strIsNotEmpty(nft) && Util.strIsEmpty(nextFireTime)) {
			return 1;
		}
		int r = catalog.compareTo(o.getCatalog());
		if (r == 0) {
			return code.compareTo(o.getCode());
		}
		return r;
	}

	public String getMemo() {
		return memo;
	}

	public void setMemo(String memo) {
		this.memo = memo;
	}

	public String getCron() {
		return cron;
	}

	public void setCron(String cron) {
		this.cron = cron;
	}

	public String getStartTime() {
		return startTime;
	}

	public void setStartTime(String startTime) {
		this.startTime = startTime;
	}

	public String getEndTime() {
		return endTime;
	}

	public void setEndTime(String endTime) {
		this.endTime = endTime;
	}

	public String getJob() {
		return job;
	}

	public void setJob(String job) {
		this.job = job;
	}

	public String getNextFireTime() {
		return nextFireTime;
	}

	public void setNextFireTime(String nextFireTime) {
		this.nextFireTime = nextFireTime;
	}

	public String getPreviousFireTime() {
		return previousFireTime;
	}

	public void setPreviousFireTime(String previousFireTime) {
		this.previousFireTime = previousFireTime;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getCatalog() {
		return catalog;
	}

	public void setCatalog(String catalog) {
		this.catalog = catalog;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getImpl() {
		return impl;
	}

	public void setImpl(String impl) {
		this.impl = impl;
	}
}
